﻿
/**
 * Data structure that represents a state
 */
public class Node
{
    /**
     * State in the state space to which the node corresponds
     * For example: In(Sibiu) or In(3)
     */
    private string mState;

    /**
     * the node(state) in the search-tree that generated this node(state)
     */
    private Node mParent;

    /**
     * Edge(action) that was applied to the parent to generate this node
     */
    private Edge mPredecessorEdge;

    /**
     * cost of the path from the initial state to this node(state)
     */
    private float mPathCost;

    /**
     * estimated costs through cheapest solution
     */
    private float mF;

    /**
     * number of steps along the path from the initial state
     */
    private int mDepth;

    /**
     * hide default constructor
     */
    private Node() { }

    /**
     * constructor
     */
    public Node(string state)
    {
        mState = state;
        mParent = null;
        mPredecessorEdge = null;
        mPathCost = float.PositiveInfinity;
        mF = float.PositiveInfinity;
        mDepth = int.MaxValue;
    }

    /**
     * override toString()
     */
    public override string ToString()
    {
        return "In(" + mState + ")";
    }

    /*
     * Getter
     */
    public string getState()    { return mState; }
    public Node getParent()     { return mParent; }
    public float getPathCost()  { return mPathCost; }
    public float getF()         { return mF; }
    public int getDepth()       { return mDepth; }

    /**
     * Setter
     */
    public void setParent(Node parent)      { mParent = parent; }
    public void setPredecessorEdge(Edge e)  { mPredecessorEdge = e; }
    public void setPathCost(float pathCost) { mPathCost = pathCost; }
    public void setF(float value)           { mF = value; }
    public void setDepth(int depth)         { mDepth = depth; }

} // class Node

